import {
  searchfn
} from '../../models/newsModel'

Page({

  data: {
    first: true,
    ret: [],
    kw: ''
  },
  onLoad(options) {

  },
  // 搜索
  search(evt) {
    // 关键词去空格
    let kw = evt.detail.value.replace(/^\s*/, '').replace(/\s*$/, '')
    if (kw === '') {
      return;
    }

    if (kw != this.data.kw) {
      searchfn(kw).then(res => {
        this.setData({
          first: false,
          ret: res.data.data.data,
          kw
        })
      })
    }








  }
})